@isTest
private class TestAccountTrigger 
{
    static testMethod void TestInsert() 
    {
 		List<Account> accounts = new List<Account>();   	
   
    	Account a;
    	
		// Test 0    	
    	a = new Account();
    	a.Name = 'UnitTest';
    	a.Phone = '1 800 GO FED EX';
		a.RecordTypeId = SilCustomerHelper.GetLocalAdvertiserAccountRecordType();
    	accounts.add(a);

		// Test 1    	
    	a = new Account();
    	a.Name = 'UnitTest2';
    	a.Phone = null;
		a.RecordTypeId = SilCustomerHelper.GetLocalAdvertiserAccountRecordType();
    	accounts.add(a);
    	
		Test.startTest();
    	insert accounts;
		Test.stopTest();
    	
    	Map<ID, Account> savedAccounts = new Map<ID, Account>([SELECT CleanPhoneText__c from Account where ID in :accounts]);
    	    	   	
    	System.assertNotEquals(null, savedAccounts.get(accounts[0].ID).CleanPhoneText__c);
    	System.assertEquals(null, savedAccounts.get(accounts[1].ID).CleanPhoneText__c);    	
    }


    static testMethod void TesUpdate() 
    {
 		List<Account> accounts = new List<Account>();   	
   
    	Account a;
    	
		// Test 0    	
    	a = new Account();
    	a.Name = 'UnitTest';
    	a.Phone = '1 800 GO FED EX';
		a.RecordTypeId = SilCustomerHelper.GetLocalAdvertiserAccountRecordType();
		insert a;
		a.Phone = null;
    	accounts.add(a);
		
		// Test 1    	
    	a = new Account();
    	a.Name = 'UnitTest2';
    	a.Phone = null;
		a.RecordTypeId = SilCustomerHelper.GetLocalAdvertiserAccountRecordType();
		insert a;
		a.Phone = '(415) 888---39281';
    	accounts.add(a);
    	
		Test.startTest();
    	update accounts;
		Test.stopTest();
    	
    	Map<ID, Account> savedAccounts = new Map<ID, Account>([SELECT CleanPhoneText__c from Account where ID in :accounts]);
    	    	   	
    	System.assertEquals(null, savedAccounts.get(accounts[0].ID).CleanPhoneText__c);
    	System.assertNotEquals(null, savedAccounts.get(accounts[1].ID).CleanPhoneText__c);    	
    }
}